package com.lzx.applib.utils;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * Created by Administrator on 2016/11/3.
 */

public class TestDataUtil {

    public static final char[] Letters = new char[] {
            'a', 'b', 'c', 'd', 'e', 'f', 'g',
            'h', 'i', 'j', 'k', 'l', 'm', 'n',
            'o', 'p', 'q', 'r', 's', 't',
            'u', 'v', 'w', 'x', 'y', 'z'
    };

    private static String getRandomString(int length) {
        Random random = new Random();
        if (length == -1) {
            length = random.nextInt(5)+2;
        }
        StringBuilder builder = new StringBuilder();
        while(length-- > 0) {
            builder.append(Letters[random.nextInt(Letters.length)]);
        }
        return builder.toString();
    }

    public static List<String> getStringList(int size, boolean allNum, boolean sameLength) {
        List<String> data = new ArrayList<>();
        for (int i=0; i<size; i++) {
            data.add(allNum ? ("" + i) : getRandomString(sameLength ? 3 : -1));
        }
        return data;
    }
}
